<template>
	<view class="main">
		<lb-picker :props='props0' @confirm='confirm0' ref='Picker0' :list='list0'></lb-picker>
		<lb-picker :props='props' @confirm='confirm' ref='Picker1' :list='list'></lb-picker>
		<lb-picker :props='props2' @confirm='confirm2' ref='Picker2' :list='list2'></lb-picker>
	<view class="active_tit">
		<view class="tit">
			共同借款人信息
		</view> 
	</view>	
		<block v-for="(item,index) in stdOffsurCoBorrowerBasic" :key="index+'a'">
			<view class="cut">客户信息{{index+1}}  <uni-icons class="clear" type="clear" @click='stdDel(stdOffsurCoBorrowerBasic,item,"stdOffsurCoBorrowerBasic")'></uni-icons>
			</view>
			
			<ActiveForm style="width: 100%;" v-if="!item.uuid">
				<view class="active_label">
					<button :disabled='!!item.uuid' @click="openOcr(item)" size="mini" type="primary">身份证识别</button>
				</view>	
			</ActiveForm>

			<ActiveForm required ref='borrowerName'>
				<view class="active_label">
					姓名：
				</view>
				<view class="active_input">
					<input :disabled='!!item.uuid'  type="text" v-model.trim="item.borrowerName" />
				</view>
			</ActiveForm>
			
			<ActiveForm required ref='certificatesType'>
				<view class="active_label">
					证件类型：
				</view>
				<view class="active_input">
					<SelectPicker :disabled='!!item.uuid'  v-model="item.certificatesType" :options="maritalIdTypeOptions" placeholder="请选择" />
				</view>
			</ActiveForm>
			<ActiveForm required  ref='certificatesNumber'>
				<view class="active_label">
					证件号码：
				</view>
				<view class="active_input">
					<input :disabled='!!item.uuid'  type="text" @input="cardCheck($event,item)" v-model.trim="item.certificatesNumber"  maxlength="18" />
				</view>
			</ActiveForm>
			<ActiveForm required>
				<view class="active_label">
					证件有效期起始日：
				</view>
				<view class="active_input">
					<view v-if="!item.certificatesNumber" >请先输入证件号码</view>
					<picker v-else style="width: 100%;" mode="date" :value="item.startDate"   @change="(o)=>{item.startDate=o.target.value}">
					    <view >{{item.startDate}}</view>
					</picker>
				</view>
			</ActiveForm>
			<ActiveForm required>
				<view class="active_label">
					证件有效期终止日：
				</view>
				<view class="active_input">
					<view v-if="!item.certificatesNumber">请先输入证件号码</view>
					<picker v-else style="width: 70%;" mode="date" :value="item.endDate"   @change="(o)=>{item.endDate=o.target.value}">
					    <view >{{item.endDate}}</view>
					</picker>
					<button   type="primary" size="mini" @click="()=>{item.endDate='长期'}">长期</button>
				</view>
			</ActiveForm>
			
			<ActiveForm required  ref='borrowerMoblie'>
				<view class="active_label">
					手机号码：
				</view>
				<view class="active_input">
					<input :disabled='!!item.uuid' type="text" @input="numCheck2($event,item)" v-model.trim="item.borrowerMoblie" maxlength="11" />
				</view>
			</ActiveForm>
			<ActiveForm   ref='borrowerEmail'>
				<view class="active_label">
					邮箱：
				</view>
				<view class="active_input">
					<input placeholder="此邮箱用于电子合同送达。" type="text"  v-model="item.borrowerEmail" />
				</view>
			</ActiveForm>
			
			<ActiveForm required  ref='homeAddress'>
				<view class="active_label">
					家庭地址：
				</view>
				<view class="active_input">
					<!-- <input type="text" v-model="item.address" /> -->
					<RegionPicker :value="address(item.homeAddress)"  :options="region"  @change="((o)=>{item.homeAddress=o.value.toString()})"    />
					
				</view>
			</ActiveForm>
			<ActiveForm required  ref='homeAddrsDetail'>
				<view class="active_label">
					家庭详细地址：
				</view>
				<view class="active_input">
					<input type="text" v-model="item.homeAddrsDetail" />
				</view>
			</ActiveForm>
			<ActiveForm required  ref='maritalStatus'>
				<view class="active_label">
					婚姻状况：
				</view>
				<view class="active_input">
					<SelectPicker v-model="item.maritalStatus" :options="maritalStatusOptions" placeholder="请选择" />
				</view>
			</ActiveForm>
			<ActiveForm required  ref='identityAttribute'>
				<view class="active_label">
					身份属性：
				</view>
				<view class="active_input">
					<SelectPicker  @change='select($event,index)' :disabled='!!item.uuid' v-model="item.identityAttribute" :options="ideyAttributeOption" placeholder="请选择" />
				</view>
			</ActiveForm>
			<ActiveForm required  ref='otherIncome'>
				<view class="active_label">
					其他年收入（元）：
				</view>
				<view class="active_input">
					<mInput type="text" v-model="item.otherIncome" />
				</view>
			</ActiveForm>
			<!-- 征信  税务-->
			<view class="btn"  style="width: 100%;margin-top: 5rem;"> 
				<button v-if="!item.uuid"  type="primary" size="mini" @click="save(item)">保存</button>
				<block v-else>
					<button type="default" size="mini" @click="qcode(item.auth)">共同借款人授权</button>
					<button type="primary" :disabled="item.auth.isAuth=='未授权'" size="mini" @click="look(item.auth)">查看征信报告</button>
					<!-- <button type="primary" :disabled="item.auth.isAuth=='未授权'" size="mini" @click="look2(item.auth)">查看税务数据</button> -->
					<button type="primary" size="mini" @click="refresh(item)">刷新</button>
				</block>
				
			</view>
			
			<!-- 资产信息 -->
			<view class="active_tit">
				<view class="tit">
					个人资产情况（房产类/土地类）
				</view>
			</view>
			<block v-for="(zitem,zindex) in item.stdOffsurCollateral" >
				<view class="cut">房产{{zindex+1}} 【为避免楼栋号，房号输入不准确，请点击【精准选择】按钮选择确认。】 <uni-icons class="clear" type="clear" @click='stdDel(item.stdOffsurCollateral,zitem,"stdOffsurCoBorrowerBasic")'></uni-icons>
				</view>
			
				<ActiveForm required ref=''>
					<view class="active_label">
						房产性质：
					</view>
					<view class="active_input">
						<SelectPicker v-model="zitem.buildingAttr" :options="buildingAttrOption" placeholder="请选择" />
					</view>
				</ActiveForm>
				
				<ActiveForm required ref='mortgageAdd'>
					<view class="active_label">
						资产所在地区：
					</view>
					<view class="active_input">
						<RegionPicker :value="mortgageAdd(zitem.mortgageAdd)" :options="region2" @change="((o)=>{zitem.mortgageAdd=o.value.toString()})" />
					</view>
				</ActiveForm>
			
				<ActiveForm required ref='buildingName'>
					<view class="active_label">
						楼盘名称：
					</view>
					<view class="active_input">
						<input type="text" v-model="zitem.buildingName" placeholder="关键字查询" />
						<button type="pg" @click="selectXx(zindex,'buildingName',0,zitem,index)">楼盘查询</button>
					</view>
				</ActiveForm>
				<ActiveForm required ref='buildingNo'>
					<view class="active_label">
						楼栋号（号数）：
					</view>
					<view class="active_input">
						<input type="text" :disabled='zcDisabled' v-model="zitem.buildingNo" />
						<button type="pg" @click="selectXx(zindex,'buildingNo',1,zitem,index)">精准选择</button>
					</view>
				</ActiveForm>
				<ActiveForm required ref='floor'>
					<view class="active_label">
						所在楼层（层数）：
					</view>
					<view class="active_input">
						<input @input="fcInout(zitem)" type="number" v-model="zitem.floor" />
			
					</view>
				</ActiveForm>
				<ActiveForm required ref='floor'>
					<view class="active_label">
						房号（号数）：
					</view>
					<view class="active_input">
						<input :disabled='zcDisabled' type="text" v-model="zitem.roomNo" />
						<button type="pg" @click="selectXx(zindex,'roomNo',2,zitem,index)">精准选择</button>
					</view>
				</ActiveForm>
				<ActiveForm required ref='allFloor'>
					<view class="active_label">
						总层数（层数）：
					</view>
					<view class="active_input">
						<mInput :thousand='false' type="number" v-model="zitem.allFloor" />
					</view>
				</ActiveForm>
				<ActiveForm required ref='area'>
					<view class="active_label">
						面积（平方米）：
					</view>
					<view class="active_input">
						<mInput @input="fcInout(zitem)" :thousand='false' type="number" v-model="zitem.area" />
					</view>
				</ActiveForm>
				<ActiveForm required ref='guaranteeBalance'>
					<view class="active_label">
						贷款余额（元）：
					</view>
					<view class="active_input">
						<mInput placeholder='此套房产的所有抵押贷款' maxlength="16" type="number" v-model="zitem.guaranteeBalance" />
					</view>
				</ActiveForm>
				<ActiveForm required ref='autoAssessPrice'>
					<view class="active_label">
						评估价值（线上）：
					</view>
					<view class="active_input">
						<mInput type="number" :disabled="true" v-model="zitem.autoAssessPrice" />
						<button type="pg" @click="pg(zitem,index)">线上评估</button>
					</view>
				</ActiveForm>
				<ActiveForm required ref='manAssessPrice'>
					<view class="active_label">
						评估价值（人工）：
					</view>
					<view class="active_input">
						<mInput maxlength="16" type="number" v-model="zitem.manAssessPrice" />
					</view>
				</ActiveForm>
				<ActiveForm required ref='residue'>
					<view class="active_label">
						剩余价值（元）：
					</view>
					<view class="active_input">
						<mInput type="number" :disabled="true" :value="sy(zitem)" />
					</view>
				</ActiveForm>
				<ActiveForm required ref='residue'>
					<view class="active_label">
						备注：
					</view>
					<view class="active_input">
						<input type="text"  v-model="zitem.remark" />
					</view>
				</ActiveForm>
				<block v-for="(qitem,qindex) in zitem.obligeeNameList" >
					<view class="cut">权利人{{qindex+1}}
						<uni-icons class="clear" type="clear" @click='stdDel(zitem.obligeeNameList,qitem,"stdOffsurCoBorrowerBasic")'></uni-icons>
					</view>
				
					<ActiveForm required ref=''>
						<view class="active_label">
							权利人名称：
						</view>
						<view class="active_input">
							<input type="text" v-model="qitem.pledgorName" />
						</view>
					</ActiveForm>
				
				</block>
				<view class="active_tit">
					<view class="tit">
					</view>
					<view class="add" @click="addUser(zitem)">
						添加权利人
					</view>
				</view>
			</block>
			
			<view class="active_tit">
				<view class="" style="display: flex;">
					<view class="add" @click="addCol(item)">
						添加资产
					</view>
			
				</view>
			</view>
			
			<!-- 汽车 -->
			<view class="active_tit">
				<view class="tit">
					个人资产情况（家用汽车）
				</view> 
			</view>
			<!-- input -->
			<view v-for="(citem,index) in item.stdOffsurCars" >
				<view class="cut">家用车{{index+1}} <uni-icons class="clear" type="clear" @click='stdDel(item.stdOffsurCars,citem,"stdOffsurCoBorrowerBasic")'></uni-icons></view>
				<view class="main">
					<ActiveForm required  ref=''>
						<view class="active_label">
							序号：
						</view>
						<view class="active_input">
							<input type="text" :disabled="true" v-model="citem.xh" />
						</view>
					</ActiveForm>
					<ActiveForm required  ref=''>
						<view class="active_label">
							所有权人：
						</view>
						<view class="active_input">
							<input type="text" v-model="citem.asssetsOwner" />
						</view>
					</ActiveForm>
					<ActiveForm required  ref=''>
						<view class="active_label">
							品牌型号：
						</view>
						<view class="active_input">
							<input type="text" v-model="citem.brandType" />
						</view>
					</ActiveForm>
					<ActiveForm required  ref=''>
						<view class="active_label">
							购买时间：
						</view>
						<view class="active_input">
							<!-- <input type="text" v-model="item.buyTime" /> -->
							<picker style="width: 100%;" mode="date" :value="citem.buyTime"   @change="(o)=>{citem.buyTime=o.target.value}">
							    <view >{{citem.buyTime}}</view>
							</picker>
						</view>
					</ActiveForm>
					<ActiveForm required  ref=''>
						<view class="active_label">
							购买价格（元）：
						</view>
						<view class="active_input">
							<mInput maxlength="16" type="number" v-model="citem.price" />
						</view>
					</ActiveForm>
					
					<ActiveForm  required  ref=''>
						<view class="active_label">
							车牌号码：
						</view>
						<view class="active_input">
							<input type="text" v-model="citem.carCode" />
						</view>
					</ActiveForm>
					<ActiveForm   ref=''>
						<view class="active_label">
							备注：
						</view>
						<view class="active_input">
							<input type="text" v-model="citem.remark" />
						</view>
					</ActiveForm>
				</view>
			</view>
			<view class="active_tit">
				<view class="" style="display: flex;">
					<view class="add" @click="addCar(item)">
						新增家用车
					</view>
				</view>
			</view>
			<ActiveForm required  ref=''>
				<view class="active_label">
					购买价格总计：
				</view>
				<view class="active_input">
					<input type="number"  :disabled="true" v-model="item.goumaizongjia" />
				</view>
			</ActiveForm>
			<!-- <ActiveForm required  ref=''>
				<view class="active_label">
					贷款余额总计：
				</view>
				<view class="active_input">
					<input type="number"  :disabled="true" v-model="item.zongjia" />
				</view>
			</ActiveForm> -->

		</block>
		
		
		<view class="active_tit">
			<view class="" style="display: flex;">
				<view class="add" @click="addCo2" v-if="loanType==='4'">
					添加抵押人作为共同借款人
				</view>
				<view class="add" @click="addCo">
					新增共同借款人
				</view>
			</view>
		</view>
		
		<!-- 弹框 -->
		<popup ref='popupCo' type="info" :showCancel="false" @confirm='pclick'>
			<view class="qcode">
				<text style="font-size: 2.8rem;">请使用手机自带浏览器扫描</text>
				<tki-qrcode :size='400' ref="qrcodeCob" :val="val" :showLoading="true" style="width: 100%;height: 100%;" />
			</view>
		</popup>
		<uni-popup ref="popups" type="dialog" style="width: 70rem;height: 40rem;">
			<uni-popup-dialog @confirm='zxbgcon' title="征信报告" type="info" :duration="2000"
				style="width: 100%;height: 100%;">
				<scroll-view scroll-y="true" style="height: 70rem;">
					<view class="zx" v-append="zxbg" @appended="appended"></view>
				</scroll-view>
			</uni-popup-dialog>
		</uni-popup>
		<uni-popup ref="popup3" type="dialog" style="width: 40rem;height: 40rem;">
			<uni-popup-dialog @confirm='zxbgcon2' title="税务数据" type="info" :duration="2000"
				style="width: 100%;height: 100%;">
				<scroll-view scroll-y="true" style="height: 70rem;">
					<n-table :tableHeight="200" ref="table1" :nameOpt="{title:'纳税人基本信息'}" colKey='prop' :columns='col' :tableData='tableData'></n-table>
					<n-table ref="table3" :nameOpt="{title:'查询企业增值税申报行为'}" colKey='prop' :columns='col3' :tableData='tableData3'></n-table>
					<n-table ref="table2" :nameOpt="{title:'查询企业所得税申报行为'}" colKey='prop' :columns='col2' :tableData='tableData2'></n-table>
				</scroll-view>
			</uni-popup-dialog>
		</uni-popup>
		
		<!-- 证件OCR -->
		<uni-popup ref="imgPopups" type="dialog" style="width: 70rem;height: 40rem;">
			<uni-popup-dialog @confirm='ocrImg2' :before-close="true" @close="ocrClose" title="选择影像" type="info" :duration="2000"
				style="width: 100%;height: 100%;">
				<view style="width: 100rem;height:50rem;display:flex;">
					<view style="display:flex;justify-content: center;flex-direction: column;align-items: center;">
						<button  @click="chooseImg2('1')" size="mini" type="primary">选择身份证正面</button>
						<image style='width: 50rem;height: 25rem;' :src="ocrImgUrl1" mode=""></image>
					</view>
					<view style="display:flex;justify-content: center;flex-direction: column;align-items: center;">
						<button  @click="chooseImg2('2')" size="mini" type="primary">选择身份证反面</button>
					    <image style='width: 50rem;height: 25rem;' :src="ocrImgUrl2" mode=""></image>
					</view>
				</view>
			</uni-popup-dialog>
		</uni-popup>
		

	</view>
</template>

<script>
	import chooseImgToBase64 from "@/utils/chooseImgToBase64";
	import tkiQrcode from "@/components/tki-qrcode/tki-qrcode.vue"
	import uniPopupDialog from "@/components/uni-popup-dialog/uni-popup-dialog.vue";
	import SelectPicker from "../../SelectPicker";
	import RegionPicker from "../../RegionPicker";
	import region from '../areaList.js'
	export default {
		name: 'userInfo',
		data() {
			return {
				ocrImgUrl1:'',
				ocrImgUrl2:'',
				ocrImgData1:'',
				ocrImgData2:'',
				ocrTypes:'',
				ocrItem:{},
				
				loanType:'',
				ideyAttributeOption:[],
				tableData:[],
				col:[],
				tableData2:[],
				col2:[],
				tableData3:[],
				col3:[],
				val: '',
				zxbg: '',
				selectIndex:'',
				selectName:'', 
				selectNode:'', 
				goumaizongjia:'',
				zongjia:'',
				region2:[],
				buildingAttrOption:[],
				pledgorTypeOption:[],
				idenTypeOption:[],
				pledgorIdenAttOption:[],
				stdOffsurCars:[{}],
				stdOffsurCollateral01:[{}],
				props0: {
					label: 'projectName',
					value: 'projectId'
				},
				props: {
					label: 'buildingName',
					value: 'buildingName'
				},
				props2: {
					label: 'houseName',
					value: 'houseName'
				},
				list: [],
				list0: [],
				list2: [],
				zcDisabled: true,
				isdisabled:false,
				region,
				province: "",
				city: "",
				county: "",
				index: 1,
				stdOffsurCoBorrowerBasic:[] ,
				maritalIdTypeOptions: [],
				vocationOptions: [],
				maritalStatusOptions: [],
				educationOptions:[],
				liveConditionOptions:[],
				required:false
			}
		},
		components: {
			SelectPicker,
			RegionPicker
		},
		computed:{
			sy() {
				return function(item) {
					if(this.loanType==='4'){
						item.residue = item.manAssessPrice - item.guaranteeBalance
						
					}else{
						//console.log(item)
						item.residue = item.autoAssessPrice != '' && item.autoAssessPrice != '0' ? item.autoAssessPrice - item.guaranteeBalance :
							Number(item.manAssessPrice)  - Number(item.guaranteeBalance)
					}
					
					if(item.residue<0){
						return 0
					}else{
						//console.log(item.residue)
						if(isNaN(item.residue) ){
							return 0
						}else{
							return item.residue
						}
						
					}
				}
			},
			mortgageAdd() {
				return function(val) {
					if (val == '' || val == null) {
						return []
					} else {
						let arr = val.split(",")
						return arr
					}
				}
			},
			address(){
				return function(val){
					//debugger
				        if(val==''||val==null){
				        	return []
				        }else{
				        	return val.split(",")
				        }
				      }
			}
		},
		mounted() {
			//获取返显数据
			setTimeout(()=>{
				this.loanType = getApp().globalData.stdOffsurBaiscInfo.loanType
				//自然人类型 身份属性 只有 配偶 或关联人
				if(getApp().globalData.stdOffsurBaiscInfo.appluserType ==='1'){
					this.ideyAttributeOption = [
						{label:'申请人配偶',value:'10'},
						{label:'关联人',value:'06'}
					]
				}else{
					this.ideyAttributeOption = getApp().globalData.optType.IDEN_ATT_COB //自然人
				}
				
				this.region2 = getApp().globalData.FxtData
				//获取下拉类型
				this.stdOffsurCoBorrowerBasic = getApp().globalData.stdOffsurCoBorrowerBasic||[]
				this.isdisabled = getApp().globalData.indDisabled
				this.maritalStatusOptions = getApp().globalData.optType.MARITAL
				this.educationOptions = getApp().globalData.optType.EDU
				this.maritalIdTypeOptions = getApp().globalData.optType.IDENT
				this.liveConditionOptions = getApp().globalData.optType.LIVE
				this.vocationOptions = getApp().globalData.optType.VOCATIO
				
				this.buildingAttrOption = getApp().globalData.optType.BUL_ATT
				this.pledgorTypeOption = getApp().globalData.optType.SUBJECT
				this.idenTypeOption = getApp().globalData.optType.PLEDGOR_IDEN
				this.pledgorIdenAttOption = getApp().globalData.optType.PLEDGOR_IDEN_ATT
				
			},getApp().globalData.timeout)
		},
		watch:{
			stdOffsurCoBorrowerBasic:{
				handler:function(res){
					// console.warn('stdOffsurCoBorrowerBasic组件数据变化',res)
					getApp().globalData.stdOffsurCoBorrowerBasic = res
					for(let i=0;i<res.length;i++){
						if(this.stdOffsurCoBorrowerBasic[i].stdOffsurCars&&this.stdOffsurCoBorrowerBasic[i].stdOffsurCars.length>0){
							this.stdOffsurCoBorrowerBasic[i].zongjia =  this.stdOffsurCoBorrowerBasic[i].stdOffsurCars.reduce((totalPrice, item) => totalPrice + Number(item.guarBalance), 0)
							 this.stdOffsurCoBorrowerBasic[i].goumaizongjia =  this.stdOffsurCoBorrowerBasic[i].stdOffsurCars.reduce((totalPrice, item) => totalPrice + Number(item.price), 0)
						}
						
					}
					
				},
				deep:true
			}
		},
		methods:{
			//=====新增ocr============
			openOcr(item){
				this.ocrItem = item
				this.$refs.imgPopups.open()
			},
			chooseImg2(type){
				chooseImgToBase64(
					(base64, base64SourceData, file) => {
						this.ocrTypes = file.type.split('/')
						if(type==='1'){
							this.ocrImgUrl1 = base64
							this.ocrImgData1 = base64SourceData
						}else{
							this.ocrImgUrl2 = base64
							this.ocrImgData2 = base64SourceData
						}
						
					}, 500
							
				);
				
			},
			ocrClose(){
				this.ocrImgUrl1 = ''
				this.ocrImgUrl2 = ''
				this.ocrImgData1=''
				this.ocrImgData2=''
				this.$refs.imgPopups.close()
				
			},
		
			ocrImg2(){
				if(!this.ocrImgData2||!this.ocrImgData1){
					uni.showToast({
						icon: "none",
						title: '请上传完整证件正反面影像',
						duration: 2000
					})
					return false
				}
				
				this.sendRequest({
					url: 'ocr/ocrIdCard',
					method: 'post',
					hideLoading: false,
					data: {
						"backImg": this.ocrImgData2,
						"backImgSuffix":this.ocrTypes[1],	
						"frontImg": this.ocrImgData1,
						"frontImgSuffix":this.ocrTypes[1],
						"reqId": getApp().globalData.stdOffsurBaiscInfo.reqId,
						"businessId": getApp().globalData.stdOffsurBaiscInfo.businessId,
					},
					complete: (res) => {
						if (res.code == '200') {
							this.ocrItem.borrowerName = res.data.ucName
							this.ocrItem.certificatesNumber = res.data.ucNumber
							this.ocrItem.startDate = res.data.dateStart
							this.ocrItem.endDate = res.data.dateEnd
							this.ocrClose()
						} else {
							uni.showToast({
								icon: "none",
								title: 'OCR识别失败，请重试',
								duration: 2000
							})
						}
					}
				})
				
			},
			select(e,index){
				if(this.loanType==='4'){
					if (getApp().globalData.stdOffsurBaiscInfo.appluserType == 3 || getApp().globalData.stdOffsurBaiscInfo.appluserType ==4) {
						if (e == '01') {
							uni.showToast({
								icon: "none",
								title: "【法人，个体工商户】申请，无法选择法定代表人",
								duration: 2000
							})
							setTimeout(() => {
								this.stdOffsurCoBorrowerBasic[index].identityAttribute = null
							}, 50)
						}
					
					}
					
				}
				
				
			},
			zxbgcon() {
				this.$refs.popups.close()
			},
			zxbgcon2() {
				this.$refs.popup3.close()
			},
			addCo2(){
				// 添加嗲有人作为共同借款人  getApp().globalData.stdOffsurCollateral03
				let col1 =  getApp().globalData.stdOffsurCollateral03
				let col2 =  getApp().globalData.stdOffsurCollateral04
				let col = [...col1,...col2]
				let dyUser = []
				let applyUserId =getApp().globalData.stdOffsurIndBasic.idCode
				for(let i=0;i<col.length;i++){
					let obl = col[i].obligeeNameList
					dyUser = [...dyUser,...obl]
				}
				// 过滤企业 pledgorType=2 和申请人
				
				
				for(let j=0;j<dyUser.length;j++){
					let obj = {
						borrowerName:dyUser[j].pledgorName,
						certificatesType: dyUser[j].idenType,
						certificatesNumber: dyUser[j].idenCode,
						borrowerMoblie: dyUser[j].telephone,
						maritalStatus: dyUser[j].maritalStatusCode,												
						startDate:"",
						endDate:"",
						uuid:'',
						identityAttribute:'',
						otherIncome:'',
						stdOffsurCollateral:[],
						stdOffsurCars:[],
						auth:{isAuth:'未授权'},
						
					}
					
					if(dyUser[j].pledgorType!=='2'&&dyUser[j].idenCode!==applyUserId){
						
						this.stdOffsurCoBorrowerBasic.push(obj)
					}
					
					
				}
				
			},
			// 新增共同借款人
			addCo(){
				let obj = {
					startDate:"",
					endDate:"",
					uuid:'',
					maritalStatus:'',
					identityAttribute:'',
					otherIncome:'',
					stdOffsurCollateral:[],
					stdOffsurCars:[],
					auth:{isAuth:'未授权'},
					
				}
				this.stdOffsurCoBorrowerBasic.push(obj)
			},
			addCol(item){//新增资产
			  item.stdOffsurCollateral.push({mortagageCount: '', autoAssessPrice:'',buildingName:'',obligeeNameList:[{}]})
			},
			confirm0(e) {
				console.log(e)
				this.stdOffsurCoBorrowerBasic[this.selectNode].stdOffsurCollateral[this.selectIndex][this.selectName]= e.item.projectName
				
				this.stdOffsurCoBorrowerBasic[this.selectNode].stdOffsurCollateral[this.selectIndex].projectId = e.item.projectId
			},
			confirm(e) {
				this.stdOffsurCoBorrowerBasic[this.selectNode].stdOffsurCollateral[this.selectIndex].projectId = this.list[e.index].projectId
				this.stdOffsurCoBorrowerBasic[this.selectNode].stdOffsurCollateral[this.selectIndex].buildingId = this.list[e.index].buildingId
				this.stdOffsurCoBorrowerBasic[this.selectNode].stdOffsurCollateral[this.selectIndex][this.selectName] = e.value
			},
			confirm2(e) {
				this.stdOffsurCoBorrowerBasic[this.selectNode].stdOffsurCollateral[this.selectIndex].houseId = this.list2[e.index].houseId
				this.stdOffsurCoBorrowerBasic[this.selectNode].stdOffsurCollateral[this.selectIndex][this.selectName] = e.value
			},
			addUser(item){
				item.obligeeNameList.push({})
			},
			addCar(item){
				let obj = {
					xh:item.stdOffsurCars.length + 1,
					guarBalance:'',
					price:'',
					buyTime:''
				}
				item.stdOffsurCars.push(obj)
			},
			cardCheck(e,item){ //身份证基本验证
				setTimeout(()=>{
					item.certificatesNumber = e.target.value.replace(/[^\a-\z\A-\Z0-9]/g,'')
				},50)
			},
			numCheck2(e,item){//手机号基本验证
				setTimeout(()=>{
					item.borrowerMoblie = e.target.value.replace(/[^0-9]/g,'')
				},50)
			},
			fcInout(item){
				item.autoAssessPrice = 0
			},
			pg(item, index) {
				console.log(item.mortgageAdd)
				if(!item.mortgageAdd){
					item.mortgageAdd=''
				}
				//接口评估房产
				let arr = item.mortgageAdd.split(',')
				let data = {
					"areaId": arr[2],
					"buildingName": item.buildingNo,
					"cityId": arr[1],
					"floor": item.floor,
					"houseName": item.roomNo,
					"projectName": item.buildingName,
					buildArea: item.area,
					projectId: item.projectId,
					buildingId: item.buildingId,
					houseId: item.buildingId
				}
				this.sendRequest({
					url: 'fxt/enquiry',
					method: 'post',
					hideLoading: true,
					data: data,
					complete: (res) => {
			
						if (res.code == '0') {
							item.autoAssessPrice = res.body.totalPrice
						} else {
							uni.showToast({
								icon: 'none',
								title: res.message || '评估失败',
								duration: 2000
							})
						}
					}
				})
			},
			selectXx(index, name, type,item,pindex) { //房讯通查询
				this.selectIndex = index
				this.selectName = name
				this.selectNode = pindex
			
				//接口评估房产
				//let item = this.stdOffsurCollateral01[index]
				console.log(item)
				let arr = item.mortgageAdd.split(',')
				//console.log(arr)
				if (type == 0) {
					if (item.mortgageAdd == '') {
						uni.showToast({
							icon: 'none',
							title: '请先选择资产所在地',
							duration: 2000
						})
						return false
					}
					if (item.buildingName == '') {
						uni.showToast({
							icon: 'none',
							title: '请先输入楼盘关键字',
							duration: 2000
						})
						return false
					}
			
					let data = {
						"areaId": arr[2],
						"cityId": arr[1],
						"key": item.buildingName
					}
					this.sendRequest({
						url: 'fxt/project',
						method: 'post',
						hideLoading: true,
						data: data,
						complete: (res) => {
							if (res.code == '0') {
								this.list0 = res.body
								this.$refs.Picker0.show() // 显示
							} else {
								//this.zcDisabled = false
								uni.showToast({
									icon: 'none',
									title: '楼盘获取失败，请重试',
									duration: 2000
								})
							}
			
						}
					})
			
				} else if (type == 1) {
					if (item.mortgageAdd == '') {
						uni.showToast({
							icon: 'none',
							title: '请先选择资产所在地',
							duration: 2000
						})
						return false
					}
					if (item.buildingName == '') {
						uni.showToast({
							icon: 'none',
							title: '请先输入楼盘名称',
							duration: 2000
						})
						return false
					}
					let data = {
						"areaId": arr[2],
						"buildingName": item.buildingNo,
						"cityId": arr[1],
						"floor": item.floor,
						"houseName": item.roomNo,
						"projectName": item.buildingName,
						"projectId": item.projectId
					}
					this.sendRequest({
						url: 'fxt/building',
						method: 'post',
						hideLoading: true,
						data: data,
						complete: (res) => {
							if (res.code == '0') {
								this.list = res.body
								this.$refs.Picker1.show() // 显示
							} else {
								//this.zcDisabled = false
								uni.showToast({
									icon: 'none',
									title: '楼栋号获取失败,请重试',
									duration: 2000
								})
							}
			
						}
					})
				} else {
					if (!item.buildingId) {
						uni.showToast({
							icon: 'none',
							title: '请先精准获取楼栋号',
							duration: 2000
						})
						return false
					}
					if (!item.floor) {
						uni.showToast({
							icon: 'none',
							title: '请输入楼层',
							duration: 2000
						})
						return false
					}
					let data = {
						"cityId": arr[1],
						"buildingId": item.buildingId,
						"floor": item.floor,
						"areaId": arr[2],
						"buildingName": item.buildingNo,
					}
					this.sendRequest({
						url: 'fxt/house',
						method: 'post',
						hideLoading: true,
						data: data,
						complete: (res) => {
							if (res.code == '0') {
								this.list2 = res.body
								this.$refs.Picker2.show() // 显示
							} else {
								//this.zcDisabled = false
								uni.showToast({
									icon: 'none',
									title: '房号获取失败,请重试',
									duration: 2000
								})
							}
			
						}
					})
				}
			},
			
			
			//查看二维码
			qcode(item) {
				console.log(item)
				this.val = ''
				this.val = getApp().globalData.toUrl + '?reqId=' + getApp().globalData.stdOffsurBaiscInfo.reqId +
					'&&tobeId=' + item.id + '&&tobeAuthType=' + item.tobeAuthType +
					'&&customerType=' + item.customerType + '&&entityRoleType=' + item.entityRoleType + '&&customerName=' +
					item.customerName
				this.$refs.popupCo.open('', '授权二维码')
				console.warn(this.val)
				setTimeout(() => {
					this.$refs.qrcodeCob._makeCode()
				}, 500)
			
			},
			pclick(item) {
				this.$refs.qrcodeCob._clearCode()
			this.$refs.popupCo.close()
			},
			look(item){
				// /offsur/query/subjectData
				this.sendRequest({
					url: 'offsur/query/subjectData',
					method: 'post',
					hideLoading: false,
					data: {
						reqID:getApp().globalData.reqId,
						customerSystemId:item.customerSystemId,
						customerType:item.customerType,
						queryType:'01',
						type:'pad'
					},
					complete: (res2) => {
						console.log(res2)
						if (res2.code == '200') {
							if (!res2.data) {
								uni.showToast({
									icon: "none",
									title: '获取失败，请重试',
									duration: 2000
								})
							} else {
								this.$refs.popups.open()
								let html = res2.data.credit.htmlMessage
								this.zxbg = html
							}
			
						} else {
							uni.showToast({
								icon: "none",
								title: res2.message,
								duration: 2000
							})
						}
					}
				})
				
			},
			look2(item){
				// /offsur/query/subjectData
				this.sendRequest({
					url: 'offsur/query/subjectData',
					method: 'post',
					hideLoading: false,
					data: {
						 reqID:getApp().globalData.reqId,
						 customerSystemId:item.customerSystemId,
						 customerType:item.customerType,
						 queryType:'02',
						 type:'pad'
					},
					complete: (res2) => {
						console.log(res2)
						if (res2.code == '200') {
							if (!res2.data) {
								uni.showToast({
									icon: "none",
									title: '获取失败，请重试',
									duration: 2000
								})
							} else {
								// 表头处理
								let col = res2.data.basic.col
								for(let i=0;i<col.length;i++){
									 col[i].width = 200
								}
								this.col =col
								this.tableData =res2.data.basic.data
								let col2 = res2.data.income.col
								// for(let i=0;i<col2.length;i++){
								// 	 col2[i].width = 120
								// }
								this.col2 =col2
								this.tableData2 =res2.data.income.data
								let col3 = res2.data.vat.col
								this.col3 =col3
								this.tableData3 =res2.data.vat.data
								
								this.$refs.popup3.open()
								
							}
				
				
						} else {
							uni.showToast({
								icon: "none",
								title: res2.message,
								duration: 2000
							})
						}
					}
				})
				
			},
			
			save(item) {
				//console.log(item)
				if (!item.borrowerName) {
					uni.showToast({
						title: '共借：' + item.borrowerName +
							',名称不能为空！',
						icon: "none",
						duration: 2000
					})
					return false
				}
				if (!item.borrowerMoblie) {
					uni.showToast({
						title: '担保：' + item.borrowerName + ',手机号不能为空！',
						icon: "none",
						duration: 2000
					})
					return false
				}
				if (!item.certificatesNumber) {
					uni.showToast({
						title: '担保：' + item.borrowerName +
							',证件号码不能为空！',
						icon: "none",
						duration: 2000
					})
					return false
				}
				if (!item.identityAttribute) {
					uni.showToast({
						title: '担保：' + item.borrowerName +
							',身份属性不能为空！',
						icon: "none",
						duration: 2000
					})
					return false
				}
				if (!item.homeAddress) {
					uni.showToast({
						title: '担保：' + item.borrowerName +
							',住所（通讯地址）不能为空！',
						icon: "none",
						duration: 2000
					})
					return false
				}
				
				// 证件有效期校验
				// 202206反洗钱需求校验
				if(!item.endDate||!item.startDate){
					uni.showToast({
						title: '共借人客户证件有效期不能为空',
						icon: "none",
						duration: 2000
					})
					return false
					
				}
				let nowDate= new Date().getTime()
				let endDate = new Date(item.endDate).getTime()
				let startDate = new Date(item.startDate).getTime()
				if(item.endDate!="长期"){
						if(nowDate>endDate){
							uni.showToast({
								title: '共借人客户证件已过期，请核实并更新证件后提交！',
								icon: "none",
								duration: 2000
							})
							return false
						}
						if(nowDate<startDate){
							uni.showToast({
								title: '共借人客户证件起始时间大于当前时间，请核实并更新证件后提交！',
								icon: "none",
								duration: 2000
							})
							return false
						}
				}else{
					if(nowDate<startDate){
						uni.showToast({
							title: '共借人客户证件起始时间大于当前时间，请核实并更新证件后提交！',
							icon: "none",
							duration: 2000
						})
						return false
					}
				}
			
				this.sendRequest({
					url: '/offsur/save_borrower',
					method: 'post',
					hideLoading: false,
					data: {
						stdOffsurCoBorrowerBasic: item,
						stdOffsurBaiscInfo: getApp().globalData.stdOffsurBaiscInfo,
						stdOffsursDelete: getApp().globalData.stdOffsursDelete,
					},
					complete: (res) => {
						console.log(res)
						if (res.code == '200') {
							item.uuid = res.data.offsurRelationId
							item.auth = res.data
							item.authFlag = '1'
							
							this.$emit('saveCache',true)
						} else {
							uni.showToast({
								icon: "none",
								title: res.message,
								duration: 2000
							})
						}
					}
				})
			
			},
			refresh(item){
				this.sendRequest({
					url: '/offsur/query_guarantee',
					method: 'post',
					hideLoading: true,
					data: {
						"reqId":getApp().globalData.stdOffsurBaiscInfo.reqId,
						"offsurRelationId":item.auth.offsurRelationId
					},
					complete: (res) => {
						if (res.code == '200') {
							item.auth = res.data
						} else {
							uni.showToast({
								icon: "none",
								title: res.message,
								duration: 2000
							})
						}
					}
				})
			},
			
			
			
			
			
			// ===============
			onBlur(item,name){
				if(!this.checkIDCard(this.stdOffsurIndBasic.maritalIdCode)){
					this.stdOffsurIndBasic.maritalIdCode = ''
					uni.showToast({
						    icon:'none',
							title: '身份证号码无效,请重新输入！',
							duration: 2500
						});
				}
			},
			
			cardCheck2(e){
				setTimeout(()=>{
					this.stdOffsurIndBasic.maritalIdCode = e.target.value.replace(/[^\a-\z\A-\Z0-9]/g,'')
				},50)
			},
			numCheck(e){
				//console.log(e)
				setTimeout(()=>{
					this.stdOffsurIndBasic.maritalTelephone = e.target.value.replace(/[^0-9]/g,'')
				},50)
			},
			
			
		}
	}
</script>

<style lang="scss">
	.qcode {
		width: 60rem;
		height: 60rem;
		text-align: center;
	
		uni-image {
			width: 100%;
			height: 100%;
		}
	
		image {
			width: 100%;
			height: 100%;
		}
	}
	
	
</style>
